
import request from '@/router/axios'

export function fetchTree(query) {
  return request({
    url: '/admin/dept/tree',
    method: 'get',
    params: query
  })
}
export function getTreeByUint(query) {
  return request({
    url: '/admin/dept/getTreeByUint',
    method: 'get',
    params: query
  })
}

export function addObj(obj) {
  return request({
    url: '/admin/dept/',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return request({
    url: '/admin/dept/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/admin/dept/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  return request({
    url: '/admin/dept/',
    method: 'put',
    data: obj
  })
}


export function getDeptInfo() {
  return request({
    url: '/admin/dept/getDeptList',
    method: 'get'
  })
}

export function getDeptInfoByDeptType(deptType) {
  return request({
    url: '/admin/dept/getDeptList/'+deptType,
    method: 'get'
  })
}

export function getDeptInfoByDeptTypes(deptTypes) {
  return request({
    url: '/admin/dept/getDeptList/deptTypes',
    method: 'get',
    params: deptTypes
  })
}

//  分页查询部门接口
export function getDeptPage(obj) {
  return request({
    url: '/admin/dept/page',
    method: 'get',
    params: obj
  })
}


//  查询部门类型表列表
export function getDeptTypeList() {
  return request({
    url: '/admin/deptType/getDeptTypeList',
    method: 'get'
  })
}


//  根据单位获取该单位的销售部门
export function getDeptListByUnitId(unitId) {
  return request({
    url: '/admin/dept/getDeptInfoByUnitId/' + unitId,
    method: 'get'
  })
}